package com.baoyouqun.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baoyouqun.entity.UserResource;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserResourceMapper extends BaseMapper<UserResource> {

    /**
     * 批量查询用户的OWN+NEED类型资源
     *
     * @param userIds 用户ID列表（SQL中通过foreach循环）
     * @return 资源列表
     */
    @Select("""
            <script>
                SELECT id, user_id, resource_type_enum, name 
                FROM user_resource 
                WHERE user_id IN 
                <foreach collection="userIds" item="userId" open="(" separator="," close=")">
                    #{userId}
                </foreach>
            </script>
            """)
    List<UserResource> selectBatchByUserIdsAndTypes(List<String> userIds);
}